package com.redis.demo.controller;

import com.redis.demo.entity.Dept;
import com.redis.demo.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ${崔灿}
 * @date 2022/12/07 19:50
 **/
@RestController
@RequestMapping("dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    @GetMapping("/{id}")
    public Dept getById(@PathVariable Integer id){
        return deptService.findById(id);
    }
    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return deptService.delete(id);
    }
    @PostMapping
    public Dept save(@RequestBody Dept dept){

        return deptService.save(dept);
    }

    @PutMapping
    public Dept update(@RequestBody Dept dept){
        return deptService.update(dept);
    }
}
